﻿/*
#------------------------------------------------------------------------------
#-- Program Name:	[dbo].[fnConfig_IsDatabaseStandby]
#-- Purpose:		Is the database in the STANDBY mode
#--	Last Update:	05/29/2013
#--					For a complete history - please review comments in Version
#--					control.
#-- Called By:		[dbo].[spBkp_Full]
#--					[dbo].[spBkp_Differential]
#--					[dbo].[spBkp_Log]
#------------------------------------------------------------------------------
*/
CREATE FUNCTION [dbo].[fnConfig_IsDatabaseStandby]
(
	@database_name sysname		= NULL
)
RETURNS BIT
AS
BEGIN
	--- Declare Local Variables
	DECLARE	@is_standby bit
		
	--- If no database name is passed in, set the Database Name to the current database
	IF ISNULL(@database_name, '') = ''
		SELECT	@database_name = DB_NAME()

	--- Determine if the database is in standby
	SELECT	@is_standby = is_in_standby
	FROM	sys.databases
	WHERE	name = @database_name

	--- Return the Answer to the Question
	RETURN	@is_standby
END
